package com.huike.web.controller.contract;

import com.huike.clues.domain.SysUser;
import com.huike.common.annotation.Log;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.domain.entity.SysUserDTO;
import com.huike.common.core.page.TableDataInfo;
import com.huike.common.enums.BusinessType;
import com.huike.contract.domain.vo.TransferVo;
import com.huike.contract.result.TransferAssignmentData;
import com.huike.contract.service.TransferService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description 转派相关请求
 * @Date 2023-10-10
 */
@Api(tags = "转派相关接口")
@RestController
@RequestMapping("/transfer")
public class TransferController extends BaseController {

    @Resource
    TransferService transferService;

    @ApiOperation("获取转派列表")
    @PreAuthorize("@ss.hasPermi('transfer:transfer:list')")
    @GetMapping("/list")
    public TableDataInfo<List<TransferVo>> list(SysUserDTO userDTO){
        //调用transferService的selectTransferList方法获取转派列表
        List<TransferVo> list = transferService.selectTransferList(userDTO);
        //调用getDataTablePage方法返回分页数据
        return getDataTablePage(list);
    }

    @ApiOperation("转派处理")
    @PreAuthorize("@ss.hasPermi('transfer:transfer:assignment')")
    @PutMapping("/assignment/{type}/{userId}/{transferUserId}")
    public AjaxResult<TransferAssignmentData> assignment(@PathVariable("type") String type, @PathVariable("userId") Long userId, @PathVariable("transferUserId") Long transferUserId) {
        //调用transferService的assignment方法处理转派
        return AjaxResult.success(transferService.assignment(type, userId, transferUserId));
    }
}
